class Solution {
    public int findMaxForm(String[] strs, int m, int n) {
        int[][] dp = new int[m+1][n+1];
        for(int i=0; i<strs.length; i++){
            int zeros = 0, ones = 0;
            for(int j=0; j<strs[i].length(); j++){
                if(strs[i].charAt(j) == '0'){
                    zeros++;
                }
                else{
                    ones++;
                }
            }

            for(int k = m; k>=zeros; k--){
                for(int l = n; l>=ones; l--){
                    dp[k][l] = Math.max(dp[k][l] , dp[k-zeros][l-ones]+1);
                }
            }

        }
        return dp[m][n];
    }
}